<div class="page" id="categories">
	<?php if($this->view->func == 'index') { ?>
		<h3><a href="console" data-to="ajax">Console</a> / Categories</h3>
		<span class="advice">Create or update existing categoris plus move them around to reorder their positions.</span>
		<table>
			<tr>
				<td>
					<form class="categories_handlers">
						<div class="left"><button data-handle="new">New Category</button></div>
						<div class="clear"></div>
					</form>
				</td>
			</tr>
			<tr>
				<td class="cat">
					<div class="sortable">
						<?php if(count($this->view->data) > 0) { ?>
							<?php foreach($this->view->data as $one) { ?>
								<div class="move" id="cat_<?php echo $one['id']; ?>">
									<h4 class="left"><a href="categories/edit/<?php echo $one['link']; ?>" data-to="ajax"><?php echo $one['name']; ?></a></h4>
									<div class="actions">
										<span class="bull">•</span>
										<?php echo $one['type']; ?>
										<span class="bull">•</span>
										<a href="javascript:void(0);" class="category_delete" data-id="<?php echo $one['id']; ?>">Delete</a>
									</div>
									<span><?php echo $one['description']; ?></span>
								</div>
							<?php } ?>
						<?php } else { ?>
							<div class="delimiter"></div>
							No categories defined.
							<div class="delimiter"></div>
						<?php } ?>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<form class="categories_handlers">
						<div class="left"><button data-handle="new">New Category</button></div>
						<div class="clear"></div>
					</form>
				</td>
			</tr>
		</table>
	<?php } else { ?>
		<h3><a href="console" data-to="ajax">Console</a> / <a href="categories" data-to="ajax">Categories</a> / <?php echo $this->view->category['name']; ?></h3>
		<span class="advice">Here you can modify the category name, type and description.</span>
		<form id="form_categories">
			<input type="hidden" name="token" value="<?php echo $this->view->category['id']; ?>" />
			<div class="left half">
				<label class="input">
					<input type="text" value="<?php echo $this->view->category['id'] != 0 ? $this->view->category['name'] : ''; ?>" name="name" maxlength="70">
					<span>Name</span>
				</label>
			</div>
			<div class="right half">
				<label class="select">
					<select name="type">
						<?php foreach($this->types as $idx => $one) { ?>
							<option value="<?php echo $idx; ?>"<?php echo $this->view->category['type'] == $idx ? ' selected="selected"' : ''; ?>>Type: <?php echo $one; ?></option>
						<?php } ?>
					</select>
				</label>
			</div>
			<div class="clear"></div>
			<label class="input">
				<input type="text" value="<?php echo $this->view->category['id'] != 0 ? $this->view->category['description'] : ''; ?>" name="description" maxlength="150">
				<span>Description</span>
			</label>
			<div class="right"><button type="submit">Save</button></div>
			<div class="clear"></div>
		</form>
	<?php } ?>
</div>